﻿using System.IO;

namespace WeDonekRpc.HttpService.FileUp
{
    internal class UpStream : Stream
    {
        private readonly MemoryStream _Stream;

        public override bool CanRead => this._Stream.CanRead;

        public override bool CanSeek => this._Stream.CanSeek;

        public override bool CanWrite => this._Stream.CanWrite;

        public override long Length => this._Stream.Length;

        public override long Position { get => this._Stream.Position; set => this._Stream.Position = value; }

        public UpStream ( int capacity )
        {
            this._Stream = new MemoryStream(capacity);
        }
        public void DisposeStream ()
        {
            this._Stream.Close();
            this._Stream.Dispose();
        }
        public void Dispose ()
        {
            this._Stream.Dispose();
        }
        public void Close ()
        {
            this._Stream.Close();
        }

        public override void Flush ()
        {
            this._Stream.Flush();
        }

        public override int Read ( byte[] buffer, int offset, int count )
        {
            return this._Stream.Read(buffer, offset, count);
        }

        public override long Seek ( long offset, SeekOrigin origin )
        {
            return this._Stream.Seek(offset, origin);
        }

        public override void SetLength ( long value )
        {
            this._Stream.SetLength(value);
        }

        public override void Write ( byte[] buffer, int offset, int count )
        {
            this._Stream.Write(buffer, offset, count);
        }
    }
}
